package study.springboot.starter.app.controller;


import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;
import study.springboot.starter.tacker.TrackerKeys;

import java.util.Map;

@Slf4j
@org.springframework.web.bind.annotation.RestController
public class RestController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/rest")
    public Map<String, Object> rest() {
        log.info("i am rest, request_id={}", TrackerKeys.get());
        String response = restTemplate.getForObject("http://127.0.0.1:7000/sayHi", String.class);
        Map<String, Object> result = Maps.newHashMap();
        return result;
    }

    @RequestMapping("/sayHi")
    public Map<String, Object> sayHi() {
        log.info("i am sayHi, request_id={}", TrackerKeys.get());
        Map<String, Object> result = Maps.newHashMap();
        return result;
    }
}
